<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../../css/首页分页/active02.css">
    <link rel="stylesheet" href="../../css/bottom.css">
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_1432742_igkz8ktt0nb.css">
    <script src="../../js/rem.js"></script>
    <script src="../../js/axios.min.js"></script>
    <script src="../../js/api.js"></script>
    <script src="../../js/jquery-1.11.3.min.js"></script>
</head>

<body>
    <header>
        <a href="../../首页.html">
            <div class="iconfont icon-changyongtubiao-xianxingdaochu-zhuanqu-1"></div>
        </a>
        <h1>新品惠萃</h1>
        <span class="iconfont icon-fenxiang"></span>
    </header>
    <main>
        <div class="pic">
            <img src="../../image/shouye01-activ2.png" alt="">
            <img src="../../image/shouye01-activ2_02.png" alt="">
        </div>
        <div class="products">
            <ul>
                <!-- <li>
                    <div class="proimg" data_id="2">
                        <img src="../../image/shouye01-active2-eat.png" alt="">
                    </div>
                    <div class="surprise">惊喜价19.9元</div>
                    <p class="desc">新西兰阳</p>
                    <div class="bottom"><span class="price">￥19.90</span><span class="iconfont icon-gouwuche1"> </span>
                    </div>
                </li> -->
            </ul> 
        </div> 
    </main> 
    <script>
        axios.post(good_newGoods_Api,{
            parmas:{}
        }).then(res=>{
            console.log(res);
            var html = res.data.map(v=>
                `<li>
                    <div class="proimg" data_id = ${v.id}>
                        <img src="../../image/shouye01-active2-eat.png" alt="">
                    </div>
                    <div class="surprise">惊喜价19.9元</div>
                    <p class="desc">新西兰阳</p>
                    <div class="bottom"><span class="price">￥19.90</span><span class="iconfont icon-gouwuche1"> </span>
                    </div>
                </li>`
            ).join("")
            let ul = document.querySelector(".products ul")
            ul.innerHTML = html;
            goToCart();

        })

        let goToCart = function(){
             let goods_li = document.querySelectorAll(".proimg");
             console.log(goods_li)
             goods_li.forEach(v=>
               v.onclick = function(){
                   let id = this.getAttribute('data_id')
                   location.href = `../详情.html?id=${id}`
               }
             )
        }
    </script>
</body>

</html>